package com.simplenix.nicasio.tags;

import com.simplenix.nicasio.misc.AppException;
import com.simplenix.nicasio.misc.Internationalization;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.JspFragment;
import javax.servlet.jsp.tagext.SimpleTagSupport;

/**
 *
 * @author fronald
 */
public class String extends SimpleTagSupport {

	private java.lang.String key;

	/**
	 * Called by the container to invoke this tag.
	 * The implementation of this method is provided by the tag library developer,
	 * and handles all tag processing, body iteration, etc.
	 */
	@Override
	public void doTag() throws JspException {
		JspWriter out = getJspContext().getOut();

		try {
			JspFragment f = getJspBody();
			if (f != null) {
				f.invoke(out);
			}
			out.print(Internationalization.getInstance().getString(this.key));

		} catch (AppException ex) {
			throw new JspException("Error in String tag", ex);
		} catch (java.io.IOException ex) {
			throw new JspException("Error in String tag", ex);
		}
	}

	public void setKey(java.lang.String key) {
		this.key = key;
	}

}
